package org.iqiyi.feign;

import org.iqiyi.entity.JWT;
import org.iqiyi.feign.hystrix.AuthServiceHystrix;
import org.springframework.boot.autoconfigure.security.oauth2.resource.OAuth2ResourceServerProperties;
import org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerProperties;
import org.springframework.cloud.openfeign.FeignClient;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(value = "auth", fallback = AuthServiceHystrix.class)
public interface AuthServiceFeign {
    @PostMapping(value = "/oauth/token")
    JWT getToken(@RequestHeader(value = "Authorization") String authorization,
                                          @RequestParam("grant_type") String grantType,
                                          @RequestParam("username") String username,
                                          @RequestParam("password") String password);

    @PostMapping(value = "/oauth/token")
    JWT refreshToken(@RequestHeader(value = "Authorization") String authorization,
                 @RequestParam("grant_type") String grantType,
                 @RequestParam("refresh_token") String refresh_token);


    @PostMapping(value = "/oauth/phoneLogin")
    JWT getTokenByPhone(@RequestHeader(value = "Authorization") String authorization,
                        @RequestParam("grant_type") String grantType,
                        @RequestParam("phone") String phone,
                        @RequestParam("verifyCode") String verifyCode);
}
